package misty.mispic.app.comp

import javafx.scene.control.TreeCell
import javafx.scene.control.TreeView
import javafx.util.Callback

import java.nio.file.Path

/**
 * Created by Misty on 2015/1/24.
 */
class FileTreeCell extends TreeCell {
    static Callback factory = { TreeView tv ->
        new FileTreeCell()
    }

    @Override
    protected void updateItem(Object item, boolean empty) {
        super.updateItem(item, empty)
        if (empty || !item) {
            graphic = null
            text = null
        } else if (item instanceof Path) {
            if (item.root == item) {
                setText(item.toString())
            } else {
                setText(item.fileName.toString())
            }
            graphic = treeItem.graphic
        }
    }
}
